package com.oystertech.sportcms.service.impl;

import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.oystertech.sportcms.mapper.SysUserTeamMapper;
import com.oystertech.sportcms.model.entity.SysUserTeam;
import com.oystertech.sportcms.service.SysUserTeamService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户所属队伍实现类
 *
 * @author Oyster Cheung
 * @version V3.0.0-230824
 * @since 2023-08-24
 */
@Service
@RequiredArgsConstructor
public class SysUserTeamServiceImpl extends ServiceImpl<SysUserTeamMapper, SysUserTeam> implements SysUserTeamService {
	@Override
	public List<?> listTeamIdsByUserId(Long userId) {
		return MapUtil.toListMap(listMaps(new LambdaQueryWrapper<SysUserTeam>()
				.eq(SysUserTeam::getUserId, userId)
				.select(SysUserTeam::getTeamId)
		)).get("team_id");
	}
}
